package com.sky.controller.admin;

import com.sky.handler.RedisUtil;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import io.swagger.v3.oas.models.security.SecurityScheme;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags = "营业状态")
@Slf4j
public class status {
    @Autowired
    private RedisUtil redisUtil;

    @GetMapping("/status")
    @ApiOperation("营业状态")
    public Result<Integer> statuss(){
        log.info("status:{}",redisUtil.get("shop:status"));
        //获取营业状态
        Integer o = (Integer) redisUtil.get("shop:status");
        return Result.success(o);
    }

    @PutMapping("/{status}")
    @ApiOperation("修改营业状态")
    public Result<Integer> updateStatus(@PathVariable Integer status){
        log.info("status:{}",status);
        redisUtil.set("shop:status",status);
        return Result.success();
    }
}
